package seatiger.tomcat.coyote.http11.filters;

import seatiger.tomcat.coyote.OutputBuffer;
import seatiger.tomcat.coyote.Response;
import seatiger.tomcat.coyote.http11.OutputFilter;
import seatiger.tomcat.util.buf.ByteChunk;

import java.io.IOException;

/**
 * 不输出响应体， 通常用于响应码是204 或者是 HEAD方法请求中
 */
public class VoidOutputFilter implements OutputFilter {

    /**
     * 下一个用于执行的buffer
     */
    public OutputBuffer buffer;

    @Override
    public int doWrite(ByteChunk chunk, Response response) throws IOException {
        return chunk.getLength();
    }

    @Override
    public void setResponse(Response response) {

    }

    @Override
    public void recycle() {

    }

    @Override
    public void setBuffer(OutputBuffer buffer) {
        this.buffer = buffer;
    }

    @Override
    public long end() throws IOException {
        return 0;
    }
}
